Page({
  data: {
    isLoading: true,
    progress: 0,
    loadingImage: ''
  },

  onLoad() {
    wx.cloud.downloadFile({
      fileID: 'cloud://cloud1-7gexn9ti7088c614.636c-cloud1-7gexn9ti7088c614-1358457931/images/other/loading.jpg',
      success: res => {
        this.setData({ loadingImage: res.tempFilePath })
      }
    })

    // 模拟进度条动画
    let timer = setInterval(() => {
      if (this.data.progress < 100) {
        this.setData({ progress: this.data.progress + 2 });
      } else {
        clearInterval(timer);
        // 加载完成后隐藏loading
        setTimeout(() => {
          this.setData({ isLoading: false });
        }, 500);
        wx.reLaunch({
          url: '/pages/home/home' 
        });
      }
    }, 50);
  }
});
